<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>pic.sogou</title>
  <script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.js"></script>
	<link href="https://cdn.staticfile.org/highlight.js/9.15.6/styles/vs.min.css" rel="stylesheet">
	<script src="https://cdn.staticfile.org/highlight.js/9.15.6/highlight.min.js"></script>
  <script src="https://cdn.staticfile.org/highlight.js/9.15.6/languages/json.min.js"></script>
  <script src="https://cdn.staticfile.org/qs/6.9.0/qs.min.js"></script>
  <style>
    ::-webkit-scrollbar{ display: none; }
		*{ margin:0; padding:0; }
		html,body,#app{ height:100%; width:100%; background:#333; color:#fff; overflow: auto; }
		#tool{ position: absolute; top: 0; right: 0px; padding: 10px; }
		img.pin{ width: 32%; max-height: 100%; margin: 0.6665% }
  </style>
</head>
<body>
    <div id="app">
      <pre style="padding:0;margin:0;background:#000;"><code id="view" class="json" >加载中...</code></pre>
    </div>
  <script>
    // 代理ajax
    function proxyAjax(url, data, callback) {
      $.ajax({
        url:'http://192.168.2.94:8081/api/post',
        type:'POST',
        contentType: "application/json; charset=utf-8;",
        data: data,
        beforeSend: function (XMLHttpRequest) {
         	XMLHttpRequest.setRequestHeader("Proxy", url);
        },
        success:function(result,textStatus,jqXHR){
          if(textStatus==="success"){
            typeof callback=="function" ? callback(result) : null;
          }else{
            console.error("接口访问失败", result, textStatus, jqXHR);
          }
        },
        error:function(result,textStatus,jqXHR){
          console.error("代理服务器访问失败", result, textStatus, jqXHR);
        }
      });
    }
    $(function(){
      var query = {
        category: 'LOFTER', // 类别
        tag: '', // 标签
        start: 0, 
        len: 20,
        // width: 1920,
        // height: 1080
      }
      var url = `https://pic.sogou.com/pics/channel/getAllRecomPicByTag.jsp?${Qs.stringify(query)}`;
      proxyAjax(url, null, function(res){
        var json = JSON.parse(res||"[]");
        $("#view").text(JSON.stringify(json, null, "    ")).each(function(i, block){
          hljs.highlightBlock(block);
        });
      })
    });
  </script>
</body>
</html>